package com.sui.bigdata.sml.web.dto;

import com.alibaba.fastjson.JSON;
import com.feidee.fdcommon.util.ToolUtils;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @author songhaicheng
 * @date 2019/11/5 10:00
 * @description
 * @reviewer
 */
@Data
@Accessors(chain = true)
public class NodeDTO {
    private Long id;
    private String name;
    private Long componentId;
    private Long experimentId;
    private String style;
    private String parameters;
    private Integer status;
    private String input;
    private String output;
    private String runningConf;

    public void init() {
        initInput();
        initOutput();
        initStatus();
    }

    public void initInput() {
        if (ToolUtils.isNotNull(input)) {
            List<String> inputs = Arrays.stream(input.split(",")).map(s -> "").collect(Collectors.toList());
            input = String.join(",", inputs);
        }
    }

    public void initOutput() {
        if (ToolUtils.isNotNull(output)) {
            List<String> outputs = Arrays.stream(output.split(",")).map(s -> "").collect(Collectors.toList());
            output = String.join(",", outputs);
        }
    }

    public void initStatus() {
        status = 1;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }

}
